package com.cnhis.cloudhealth.clidoctorweb.treatment;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.treatment.service.ITreatment;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import java.util.HashMap;
import java.util.Map;

import com.cnhis.cloudhealth.commons.interceptor.SpringContextHolder;
import com.cnhis.cloudhealth.commons.redisdb.RedisResource;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;

@Path("treatment")
@Component
public class TreatmentRest
{
    Logger log = Logger.getLogger(TreatmentRest.class);
    
    @Reference
    private ITreatment treatment;
    private RedisResource redisResource = (RedisResource) SpringContextHolder.getBean("redisResource");
    /* ScriptId(754) */
    /* Description(检索门诊病人的诊断记录) */
    /**
     * 
     * @param vaa01 就诊id
     * @param acf01
     * @param vaa07 诊断记录id
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("querypatienttreatmentrecord")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo queryPatientTreatmentRecord(@FormParam("vaa01") long vaa01, @FormParam("acf01") int acf01,
        @FormParam("vaa07") long vaa07, @FormParam("currPage") int currPage, @FormParam("pageSize") int pageSize)
        throws Exception
    {
        //从数据库加载
        HashMap hs = new HashMap();
        hs.put("vaa01", vaa01);
        hs.put("acf01", acf01);
        hs.put("vaa07", vaa07);
        hs.put("currPage", currPage);
        hs.put("pageSize", pageSize);
        return treatment.queryPatientTreatmentRecord(hs, (currPage - 1) * pageSize, pageSize);
    }
    /* ScriptId(773) */
    
    /* Description(诊疗：按诊疗Id查询诊疗项目) */
    /**
     * 
     * @param BBX01 诊疗项目id
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("gettreatmentitembyid")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getTreatmentItemById(@FormParam("BBX01") int BBX01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("BBX01", BBX01);
        return treatment.getTreatmentItemById(hs);
    }
    
    
    /* Description(诊疗：按诊疗Id查询材料项目) */
    /**
     * 
     * @param BBX01 诊疗项目id
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("getCailiaoInfoBybbx01")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getCailiaoInfoBybbx01(@QueryParam("params") String params)
        throws Exception
    {
        HashMap hs = (HashMap)JsonUtil.getMap(params);
        return treatment.getCailiaoInfoBybbx01(hs);
    }
    
    // 处方诊断添加医师诊断 Clinic_VAO1_Insert
    /**
     * '{"CBMID":"17361","VAA01":"162","VAA07":"162","ACF01":"1","VAO06":"2","VAO07":"1","VAO10":"0","VAO11":"1",
     * "BAK01A":"0","CAM01":"670","VAO15","食管癌及贲门癌","VAO18":"0","VAO22":"1"}'
     * 
     * @param lxml 诊断记录
     * @param BCE03 操作者
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("insertdoctordiagnose")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo insertDoctorDiagnose(@FormParam("lxml") String lxml, @FormParam("BCE03") String BCE03)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lxml", lxml);
        hs.put("BCE03", BCE03);
        return treatment.insertDoctorDiagnose(hs);
    }
    
    // 添加常用项目
    // Clinic_BDJ1_Update
    /**
     * 
     * @param BBX01 医疗项目
     * @param BCE01 员工id
     * @param BDA01 医疗项目id
     * @param Flag
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("execclinicbdj1update")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo execClinicBDJ1Update(@FormParam("BBX01") int BBX01, @FormParam("BCE01") int BCE01,
        @FormParam("BDA01") int BDA01, @FormParam("Flag") int Flag)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("BBX01", BBX01);
        hs.put("BCE01", BCE01);
        hs.put("BDA01", BDA01);
        hs.put("Flag", Flag);
        return treatment.execClinicBDJ1Update(hs);
    }
    
    /* ScriptId(7314) */
    /* Description(个人常用诊断列表) */
    /**
     * 
     * @param bce03a 记录人
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("persontreamentlist")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo personTreamentList(@QueryParam("bce01") int bce01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("bce01", bce01);
        return treatment.personTreamentList(hs);
    }
    
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("jibingList")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo jibingList()
        throws Exception
    {
      //加载redis数据
//        return redisResource.getRedisModelVo("cag1_jibing_mz");
        //从数据库加载
        HashMap hs = new HashMap();
        return treatment.jibingList(hs);
    }
    
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("yibaoJibingList")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo yibaoJibingList(@QueryParam("params") String params)
        throws Exception
    {
        Map hs = JsonUtil.getMap(params);
        ModelVo yibaoJibingList = treatment.yibaoJibingList(hs);
		return yibaoJibingList;
    }
    
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("jibingInfo")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo jibingInfo(@QueryParam("bah01") int bah01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("bah01", bah01);
        return treatment.jibingInfo(hs);
    }
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("otherPinci")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo otherPinci()
        throws Exception
    {
        //加载redis数据
//        return redisResource.getRedisModelVo("bdi1_qitapinci_mz");
        //从数据库加载
        HashMap hs = new HashMap();
        return treatment.otherPinci(hs);
    }
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("geiyaokeshiList")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo geiyaokeshiList()
        throws Exception
    {
        HashMap hs = new HashMap();
        return treatment.geiyaokeshiList(hs);
    }
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("loadBce1")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo loadBce1(@QueryParam("bck01") int bck01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("bck01", bck01);
        return treatment.loadBce1(hs);
    }
    /**
     * 
     * @return
     * @throws Exception
     */
    @GET
    @Path("handleAdmission")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo handleAdmission()
        throws Exception
    {
        HashMap hs = new HashMap();
        return treatment.handleAdmission(hs);
    }
    /**
     * 
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("saveRuyuan")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo saveRuyuan(@QueryParam("vbn1") String vbn1,@QueryParam("vao1") String vao1,@QueryParam("vaa1") String vaa1)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vbn1", vbn1);
        hs.put("vao1", vao1);
        hs.put("vaa1", vaa1);
        return treatment.saveRuyuan(hs);
    }
    /**
     * 
     * 首页保存诊断信息
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("saveZhenduanShouye")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo saveZhenduanShouye(@FormParam("vao1") String vao1,@FormParam("vac01") long vac01)
    		throws Exception
    {
    	HashMap hs = new HashMap();
    	hs.put("vao1", vao1);
    	hs.put("vac01", vac01);
    	return treatment.saveZhenduanShouye(hs);
    }
    /**
     * 
     * 根据vao01删除诊断
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("deleteVao1ByVao01")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo deleteVao1ByVao01(@FormParam("vao01") long vao01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vao01", vao01);
        return treatment.deleteVao1ByVao01(hs);
    }
    /**
     * 
     * 首页保存诊断信息1
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("saveZhenduanShouye1")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo saveZhenduanShouye1(@FormParam("vao1") String vao1,@FormParam("cbm01") long cbm01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vao1", vao1);
        hs.put("cbm01", cbm01);
        return treatment.saveZhenduanShouye1(hs);
    }
    /**
     * 
     * 获取诊断信息
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("getZhenduanShouye")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getZhenduanShouye(@QueryParam("vac01") long vac01)
    		throws Exception
    {
    	HashMap hs = new HashMap();
    	hs.put("vac01", vac01);
    	return treatment.getZhenduanShouye(hs);
    }
    
    /**
     * 
     * 获取诊断信息
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("getZhenduanShouye1")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getZhenduanShouye1(@QueryParam("cbm01") long cbm01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("cbm01", cbm01);
        return treatment.getZhenduanShouye1(hs);
    }
    
    /**
     * 
     * 根据就诊id查询入院通知书信息
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("queryVbn1ByVac01")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo queryVbn1ByVaa07(@QueryParam("vac01") long vac01)
            throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vac01", vac01);
        return treatment.queryVbn1ByVaa07(hs);
    }
    
    /**
     * 
     * 查询所有的医疗付款方式
     */
    @SuppressWarnings("unchecked")
    @GET
    @Path("queryAbj1")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo queryAbj1(@QueryParam("params") String params)
        throws Exception
    {
        Map<String, Object> hs = JsonUtil.getMap(params);
        return treatment.queryAbj1(hs);
    }
    
}
